package com.sskj.mine.presenter;

import com.lzy.okgo.model.Response;
import com.sskj.common.base.HttpData;
import com.sskj.common.util.ToastUtil;
import com.sskj.lib.http.JsonCallBack;
import com.sskj.mine.bean.WithdrawSxf;
import com.sskj.mine.http.HttpConfig;
import com.sskj.mine.ui.activity.MineWithdrawActivity;


public class MineWithdrawActivityPresenter extends BasePresenter<MineWithdrawActivity> {
    //获取验证码
    public void sendSms(String account) {
        httpService.sendSms(account, "5")
                .execute(new JsonCallBack<HttpData>() {
                    @Override
                    public void onSuccess(Response<HttpData> response) {
                        HttpData httpData = response.body();
                        ToastUtil.showShort(httpData.getMsg());
                        if (httpData.getStatus() == HttpConfig.OK) {
                            mView.sendCheckCodeSuccess();
                        } else {
                            mView.sendCheckCodeFail();
                        }
                    }

                    @Override
                    public void onError(Response<HttpData> response) {
                        mView.sendCheckCodeFail();
                        super.onError(response);
                    }
                });
    }

    // 获取提币手续费
    public void getSxf() {
        httpService.getSxf().execute(new JsonCallBack<HttpData<WithdrawSxf>>(this) {
            @Override
            public void onSuccess(Response<HttpData<WithdrawSxf>> response) {
                HttpData<WithdrawSxf> httpData = response.body();
                ToastUtil.showShort(httpData.getMsg());
                if (httpData.getStatus() == HttpConfig.OK) {
                    mView.updateUI(httpData.getData());
                }
            }
        });
    }

    // 提币
    public void withdraw(String num, String code, String address) {
        httpService.withdraw(num, code, address).execute(new JsonCallBack<HttpData>(this) {
            @Override
            public void onSuccess(Response<HttpData> response) {
                HttpData httpData = response.body();
                ToastUtil.showShort(httpData.getMsg());
                if (httpData.getStatus() == HttpConfig.OK) {

                }
            }
        });
    }
}
